<template>
  <base-echarts :option="options" :height="height" :width="width" :clear="true"></base-echarts>
</template>

<script type="text/ecmascript-6">
  import BaseEcharts from '../base/BaseEcharts';


  /*
              https://echarts.baidu.com/examples/editor.html?c=pie-simple

              ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'] datas.dataTitle

  *            [
                {value:335, name:'直接访问'},   datas.dataContent
                {value:310, name:'邮件营销'},
                {value:234, name:'联盟广告'},
                {value:135, name:'视频广告'},
                {value:1548, name:'搜索引擎'}
              ]
  *
  *
  * */


  export default {
    name: 'pieChart',
    components: {BaseEcharts},
    props: ['datas', 'width', 'height'],
    data() {
      return {};
    },
    methods: {},
    computed: {
      options() {
        return {
          title: {
            text: this.datas.title,
            // subtext: '纯属虚构',
            x: 'center'
          },
          tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
          },
          legend: {
            orient: 'vertical',
            left: 'left',
            data: this.datas.dataTitle
          },
          series: [
            {
              name: this.datas.name,
              type: 'pie',
              radius: '55%',
              center: ['50%', '60%'],
              data: this.datas.dataContent,
              itemStyle: {
                emphasis: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
        };
      }
    }
  };
</script>
